Skip to content

Better handling of linting/packaging dependencies#680

Open
DimitriPapadopoulos wants to merge 2 commits intopypa:mainfrom
DimitriPapadopoulos:flit_version
Open

Better handling of linting/packaging dependencies#680
DimitriPapadopoulos wants to merge 2 commits intopypa:mainfrom
DimitriPapadopoulos:flit_version

Conversation

@DimitriPapadopoulos
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos commented Feb 27, 2026

Basic support for PEP 639 requires flit 3.11.

The minimal version is specified in two different places, only the first one had been updated:

wheel/pyproject.toml

Lines 1 to 2 in 56223f6

[build-system]
requires = ["flit_core >=3.11,<4"]

wheel/pyproject.toml

Lines 139 to 140 in 56223f6

[tool.tox.env.pkg]
deps = ["build", "flit >= 3.8"]

I wonder whether a single occurrence of the minimal version is possible... It appears it should be possible to specify all dependencies in a single place. Modernize dependency handling to achieve that.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.14%. Comparing base (56223f6) to head (33dee00).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #680   +/-   ##
=======================================
  Coverage   55.14%   55.14%           
=======================================
  Files          15       15           
  Lines        1206     1206           
=======================================
  Hits          665      665           
  Misses        541      541           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DimitriPapadopoulos DimitriPapadopoulos changed the title Bump minimal flit version everywhere Better handling of linting/packaging dependencies Feb 27, 2026
- Basic support for PEP 639 requires flit version 3.11. Specify it in
  a single place, the [build-system] section - tox should be able to
  read it from there.
- Intoduce a new dependency group for linting, and instruct tox to use
  it to install linting dependencies. Dependency groups require tox 4.
Copy link
Contributor

@agronholm agronholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced yet.

commands = [["pre-commit", "run", "-a"]]

[tool.tox.env.pkg]
deps = ["build", "flit >= 3.8"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you actually test this? I did, and it breaks the pkg environment because flit and build are no longer available at run-time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to test again. I thought tox would install the build system automatically. I'll have to investigate how to achieve that.

Is flit required or is flit-core enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_compare_sdists explicitly invokes both build and flit.

Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Feb 27, 2026

I'm not totally convinced myself. Rather, I am convinced that dependency groups are the proper way to define dependencies nowadays, but unsure that it is feasible to avoid specifying the build system both at the top and the bottom of pyproject.toml — which would probably be a tox shortcoming.

The latter does require more investigation, I'm sorry about that.

@agronholm
Copy link
Contributor

I'm not totally convinced myself. Rather, I am convinced that dependency groups are the proper way to define dependencies nowadays, but unsure that it is feasible to avoid specifying the build system both at the top and the bottom of pyproject.toml — which would probably be a tox shortcoming.

The latter does require more investigation, I'm sorry about that.

The dependencies in build-system are installed in isolation just for the build process. They're not made available in the test environment.

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Feb 27, 2026

I understand this is all supposed to work automatically. From the tox documentation:

Packaging

tox builds projects in a PEP 518 compatible virtual environment and communicates with the build backend according to the interface defined in PEP 517 and PEP 660. To define package build dependencies and specify the build backend to use, create a pyproject.toml at the root of the project. For example to use hatch:

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling>=0.22", "hatch-vcs>=0.2"]

Build environments

tox uses a virtual environment for building, whose name depends on the artifact type:

  • For source distributions: the package_env (default .pkg)
  • For wheels: the wheel_build_env (default .pkg-<impl><version>, e.g. .pkg-cpython313)
  • For sdist-wheel: uses two environments — the package_env for building the sdist, and the wheel_build_env (default .pkg-<impl><version>) for building the wheel from the extracted sdist

For pure Python projects (no C extensions), set wheel_build_env to the same value as package_env. This way the wheel is built once and reused for all tox environments:
``toml
[env_run_base]
package = "wheel"
wheel_build_env = ".pkg"

At least, I understand this should work, as it lets build handle the [build-system] automatically:

python -m build --sdist --no-isolation

I guess this doesn't work, as it requires the flit CLI:

python -m flit build --format=sdist

I will test all that more thoroughly, but need to understand what tests/test_sdist.py does. What exactly does it try to compare? With and without PEP 517 isolation? python -m build vs. python -m flit build? And why is that test important?

@agronholm
Copy link
Contributor

I understand this is all supposed to work automatically. From the tox documentation:

Packaging

tox builds projects in a PEP 518 compatible virtual environment and communicates with the build backend according to the interface defined in PEP 517 and PEP 660. To define package build dependencies and specify the build backend to use, create a pyproject.toml at the root of the project. For example to use hatch:

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling>=0.22", "hatch-vcs>=0.2"]

Build environments

tox uses a virtual environment for building, whose name depends on the artifact type:

  • For source distributions: the package_env (default .pkg)
  • For wheels: the wheel_build_env (default .pkg-<impl><version>, e.g. .pkg-cpython313)
  • For sdist-wheel: uses two environments — the package_env for building the sdist, and the wheel_build_env (default .pkg-<impl><version>) for building the wheel from the extracted sdist

For pure Python projects (no C extensions), set wheel_build_env to the same value as package_env. This way the wheel is built once and reused for all tox environments:
``toml
[env_run_base]
package = "wheel"
wheel_build_env = ".pkg"

At least, I understand this should work, as it lets build handle the [build-system] automatically:

python -m build --sdist --no-isolation

I guess this doesn't work, as it requires the flit CLI:

python -m flit build --format=sdist

I will test all that more thoroughly, but need to understand what tests/test_sdist.py does. What exactly does it try to compare? With and without PEP 517 isolation? python -m build vs. python -m flit build? And why is that test important?

This test was contributed to the project after a failed release when setuptools was replaced with flit as the build backand, and the sdist didn't contain the expected files. I wouldn't characterize this as an important test anymore, but I have no good reason to toss it away either. I must ask, why are you so invested in making these little changes to this project?

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Feb 27, 2026

To be honest, that's because I am fed up with the cacophony that characterizes Python development tools, at odds with the initial simplicity of the language itself. The whole ecosystem reminds of Perl ("There Is More Than One Way To Do It"). That's especially true nowadays when comparing Python to more recent languages like Go and Rust. Consistency and homogeneity, especially in the Python development tools themselves, would probably help everyone package Python software in a clean, standard and maintainable way.

@agronholm
Copy link
Contributor

Rust and Go have the advantage of hindsight, and Python had to solve problems these languages never had, and still don't have. That said, I don't see how the changes in this PR help with this at all. These changes only deal with how the wheel project itself is developed, and the requires = ["tox>=4.22"] change is the only thing here that at least marginally improves things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants